EIP-5573: SIWE ReCap
Use this crate to build wallet-signable messages with capability delegations. The generated message contains two representations of the capabilities: an unambiguous machine-readable representation, and a human-readable description. Of the two representations, the latter is deterministically generated from the former.
Message formats
We currently support the following message formats:
- EIP-4361: Sign-In With Ethereum (SIWE)
SIWE Examples
An example with:
- the capability to
present
any credential - the capability to
present
credentials of typetype1
(technically redundant) - the capability to
list
,get
and retrievemetadata
from the kepler locationkepler:ens:example.eth://default/kv
- the capability to
list
,get
, retrievemetadata
,put
anddelete
from the kepler locationskepler:ens:example.eth://default/kv/public
andkepler:ens:example.eth://default/kv/dapp-space
let credential: Namespace = "credential".parse?;
let kepler: Namespace = "kepler".parse?;
let msg: Message = new
.with_default_actions
.with_actions
.with_actions
.with_actions
.with_actions
.build?;
Which produces this SIWE message:
example.com wants you to sign in with your Ethereum account:
0x0000000000000000000000000000000000000000
I further authorize did:key:example to perform the following actions on my behalf: (1) credential: present for any. (2) credential: present for type:type1. (3) kepler: list, get, metadata for kepler:ens:example.eth://default/kv. (4) kepler: list, get, metadata, put, delete for kepler:ens:example.eth://default/kv/dapp-space, kepler:ens:example.eth://default/kv/public.
URI: did:key:example
Version: 1
Chain ID: 1
Nonce: mynonce1
Issued At: 2022-06-21T12:00:00.000Z
Resources:
- urn:recap:credential:eyJkZWYiOlsicHJlc2VudCJdLCJ0YXIiOnsidHlwZTp0eXBlMSI6WyJwcmVzZW50Il19fQ
- urn:recap:kepler:eyJ0YXIiOnsia2VwbGVyOmVuczpleGFtcGxlLmV0aDovL2RlZmF1bHQva3YiOlsibGlzdCIsImdldCIsIm1ldGFkYXRhIl0sImtlcGxlcjplbnM6ZXhhbXBsZS5ldGg6Ly9kZWZhdWx0L2t2L2RhcHAtc3BhY2UiOlsibGlzdCIsImdldCIsIm1ldGFkYXRhIiwicHV0IiwiZGVsZXRlIl0sImtlcGxlcjplbnM6ZXhhbXBsZS5ldGg6Ly9kZWZhdWx0L2t2L3B1YmxpYyI6WyJsaXN0IiwiZ2V0IiwibWV0YWRhdGEiLCJwdXQiLCJkZWxldGUiXX19
Sign-in only
A Message can be built without any capabilities, in which case a statement with only the "sign-in" message is generated:
let msg: Message = new
.build )?;
Which produces this SIWE message:
'example.com wants you to sign in with your Ethereum account:
0x0000000000000000000000000000000000000000
URI: did:key:example
Version: 1
Chain ID: 1
Nonce: mynonce1
Issued At: 2022-06-21T12:00:00.000Z